// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
import DiceController from "./DiceController";
const {ccclass, property} = cc._decorator;

@ccclass
export default class game extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property({
        type:cc.Node
    })
    DiceController: cc.Node = null;

    @property
    text: string = 'hello';
    
    // LIFE-CYCLE CALLBACKS:

     onLoad () {
        console.log("---onLoad---")
     }

    start () {
        this.label = this.node.addComponent(cc.Label)
        this.label.string =  this.text ;

        console.log(this.label.string);
    }

    
    update (dt) {
      //  console.log("--update---")
    }
    
    random() {
        cc.log("---random---")
        console.log("---random 22---")
        var DiceController =  this.node.getComponent('DiceController')
        //var DiceController = this.DiceController
        //this.DiceController.rollDice()
        DiceController.rollDice();
    }
    
    protected onDestroy(): void {
        console.log("---onDestroy---")
    }
}
